package com.example.wxtest.util;

import com.alibaba.fastjson.JSONObject;
import io.lettuce.core.ScriptOutputType;

public class sendMessage {
    public static void main(String[] args) {
        CreateMenu c = new CreateMenu();
//        获取token
        String token = c.accessToken();
        System.out.println(token);
        //发送
        JSONObject object = new JSONObject();
        JSONObject objectCon = new JSONObject();
        JSONObject objectCon1 = new JSONObject();
        JSONObject objectCon2 = new JSONObject();
        JSONObject objectCon3 = new JSONObject();
        JSONObject objectCon4 = new JSONObject();
        objectCon.put("value", "11111122");
        objectCon.put("color", "#173177");
        objectCon1.put("value", "李名");
        objectCon1.put("color", "#173177");
        objectCon2.put("value", "申通快递点");
        objectCon2.put("color", "#173177");
        objectCon3.put("value", "2000.12.12");
        objectCon3.put("color", "#173177");
        objectCon4.put("value", "success");
        objectCon4.put("color", "#173177");
        object.put("ydh", objectCon);
        object.put("fhr", objectCon1);
        object.put("zhdd", objectCon2);
        object.put("xdrq", objectCon3);
        object.put("remark", objectCon4);
        String js = "{\"touser\":\"oxQ_w6rPS7yCM36fz0JJLfPauOr8\"," +
                "\"template_id\":\"xLSYvAskYGCBciI10corF35_wiX4CkOytCQ14BOlXsQ\"," +
                "\"url\":\"https://wx.linmanou.com/#/\"," +
                "\"data\":" + object.toJSONString() + "}";
        String re = SignUtil.doPostToJson("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="
                + token, js);
        System.out.println(js);
        System.out.println(re);
    }
}
